package enumandlambda;

/**
 * @author shkstart
 * 继承Thread 创建线程
 * @create 2022-11-28-12:23
 */
public class ThreadDemo3 {
    public static void main(String[] args) {
        //获得当前的线程
        Thread mainThread = Thread.currentThread();
        System.out.println("线程名称 : " + mainThread.getName());

        Thread thread = new MyThread();
        //开启线程
        thread.start();
    }

    static class MyThread extends Thread{
        @Override
        public void run() {
            Thread thread = Thread.currentThread();
            try {
                Thread.sleep(60*60*1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("线程的名称 ： "+thread.getName());
        }
    }

}
